/**
 * 
 */
package com.munoor.dalai.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

import com.munoor.dalai.client.presenter.LoginPresenter;
import com.google.gwt.user.client.ui.Label;

/**
 * @author Osho
 * 
 */
public class LoginView extends Composite implements LoginPresenter.Display {
	@UiField Button loginButton;
	@UiField TextBox username;
	@UiField PasswordTextBox password;
	@UiField Label lblSignInError;

	private static LoginViewUiBinder uiBinder = GWT.create(LoginViewUiBinder.class);

	interface LoginViewUiBinder extends UiBinder<Widget, LoginView> {
	}

	/**
	 * Because this class has a default constructor, it can be used as a binder
	 * template. In other words, it can be used in other *.ui.xml files as
	 * follows: <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
	 * xmlns:g="urn:import:**user's package**">
	 * <g:**UserClassName**>Hello!</g:**UserClassName> </ui:UiBinder> Note that
	 * depending on the widget that is used, it may be necessary to implement
	 * HasHTML instead of HasText.
	 */
	public LoginView() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public HasClickHandlers getLoginButton() {
		// TODO Auto-generated method stub
		return loginButton;
	}

/*	@Override
	public HasClickHandlers getSignUpButton() {
		// TODO Auto-generated method stub
		return signUpButton;
	}*/

	@Override
	public Widget asWidget() {
		return this;
	}
	/*
	 * @UiHandler("button") void onClick(ClickEvent e) { Window.alert("Hello!");
	 * }
	 * 
	 * public void setText(String text) { loginButton.setText(text); }
	 *//**
	 * Gets invoked when the default constructor is called and a string is
	 * provided in the ui.xml file.
	 */
	/*
	 * public String getText() { return button.getText(); }
	 */

	@Override
	public String getUsername() {
		return username.getText();
	}

	@Override
	public String getPassword() {
		return password.getText();
	}

	@Override
	public void setSignInError(String error) {
		lblSignInError.setText(error);
		
	}

}
